#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug cout<<-1<<endl
const int maxn=1e5+5;
int t;
int n,m,l,v0;
int p[maxn];
int fa,fb;
struct node{
    int d,v,a;
    bool operator <(const node &o){
        return d<o.d;
    }
}nod[maxn];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&t);
    while(t--){
        for(int i=1;i<=n;i++){
            nod[i].a=0; nod[i].d=0; nod[i].v=0;
        }
        memset(p,0,sizeof(p));
        fa=1;fb=1;
        scanf("%lld%lld%lld%lld",&n,&m,&l,&v0);
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&nod[i].d,&nod[i].v,&nod[i].a);
            if(nod[i].a!=0)fa=0;
            if(nod[i].a<=0)fb=0;
        }
        for(int i=1;i<=m;i++){
            scanf("%lld",&p[i]);
        }
        sort(p+1,p+m+1);
        if(fa){
            sort(nod+1,nod+n+1);
            int ans=0;
            for(int i=1;i<=n;i++){
                if(nod[i].d<=p[m]&&nod[i].v>v0){
                    ans++;
                }
                else if(nod[i].d>p[m]){
                    break;
                }
            }
            cout<<ans<<" "<<m-1<<endl;
        }
        else {
            sort(nod+1,nod+n+1);
            int ans=0;
            for(int i=1;i<=n;i++){
                if(nod[i].d<=p[m]&&v0*v0-nod[i].v*nod[i].v<2*nod[i].a*(p[m]-nod[i].d)){
                    ans++;
                }
                else if(nod[i].d>p[m]){
                    break;
                }
            }
            cout<<ans<<" "<<m-1<<endl;

        }
        /*
        else if(n<20&&m<20){

        }
        */

    }




}
